#!/bin/bash

function find_process(){
	ps -ef | grep $1 | grep -v grep | grep -v run.sh 
}

function find_process_wc(){
	ps -ef | grep $1 | grep -v grep | grep -v run.sh | wc -l
}

function check_process_parallel(){
     #find_process $1
     wc=`find_process_wc $1`
     parall=$2
     if [ $wc -ge $parall ];then
        #echo $wc $parall
	echo true
     else 
        #echo "$wc -gt $parall"
        echo false
     fi
}

function run(){
     for path in $@
     do
	echo $path #here to execute script
	#check_process_parallel st-history.jar 1
        while "$(check_process_parallel st-history.jar 1)"
	do
		sleep 2
	done
     done
}

run $@

